using ASP;
using IPMS.BLL;
using System;
using System.Configuration;
using System.Data.Common;
using System.Data.SqlClient;
using System.Globalization;
using System.Threading;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class FilterProject : Page, IRequiresSessionState
{
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string ownergroupID = this.Session["OwnerGroupID"].ToString();
        foreach (GridViewRow gvRow in this.gvwResult.Rows)
        {
            CheckBox cb = (CheckBox)gvRow.FindControl("chkSelect");
            if ((cb != null) && cb.Checked)
            {
                try
                {
                    new ProductProject(this.txtProduct.Text, this.gvwResult.DataKeys[gvRow.RowIndex].Values["ProjectCode"].ToString(), this.Page.User.Identity.Name.ToString(), this.Page.User.Identity.Name.ToString(), ownergroupID).SetProductProject();
                }
                catch (Exception)
                {
                }
            }
        }
        string scriptStr = "<script>window.close();</script>";
        base.ClientScript.RegisterClientScriptBlock(typeof(string), "closing", scriptStr);
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        this.gvwResult.DataBind();
    }

    protected override void InitializeCulture()
    {
        string sCulture = ConfigurationManager.AppSettings["DefaultCulture"].ToString();
        try
        {
            sCulture = this.Session["Culture"].ToString();
        }
        catch (NullReferenceException)
        {
        }
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(sCulture);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(sCulture);
        base.InitializeCulture();
    }

    protected void ODSProject_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        SqlParameter[] sqlparam = new SqlParameter[] { new SqlParameter() };
        sqlparam[0].ParameterName = "@ProjectCode";
        sqlparam[0].Value = this.txtProjectCode.Text;
        DbParameter[] param = sqlparam;
        e.InputParameters[0] = "_IPMS_ProjectSearch1_Sp";
        e.InputParameters[1] = param;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            this.txtProduct.Text = base.Request.QueryString["Model"].ToString();
        }
    }
}
